package com.kim.common.base;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.google.common.base.CaseFormat;
import lombok.Data;

/**
 * Created on 2021/1/20.
 *
 * @author xienaifa
 */
@Data
public class Page {
    /**
     * 分页详情
     */
    @TableField(exist=false)
    private Integer page ;
    @TableField(exist=false)
    private Integer pageSize ;

    /**
     * 排序字段
     */
    @TableField(exist=false)
    private String sortOrder;

    @TableField(exist=false)
    private String sortField;

    public Page() {
        this.page = 1;
        this.pageSize = 10;
    }

    public void setSortOrder(String sortOrder) {
        this.sortOrder = sortOrder;
    }

    public void setSortField(String sortField) {
        if (StringUtils.isNotBlank(sortField)){
        this.sortField = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sortField);}
    }
}
